Playground execution failed: error: 20170520-221301.xcplaygroundpage:42:1: error: type 'String' does not conform to protocol 'BCompatible' extension String: BCompatible { } // ここで error: type 'String' does not conform to protocol 'BCompatible' が出る 20170520-221301.xcplaygroundpage:24:9: note: protocol requires property 'bEx' with type 'String.CompatibleType' (aka 'AExample<String>'); do you want to add a stub? var bEx: CompatibleType { get } ^ 20170520-221301.xcplaygroundpage:36:9: note: candidate has non-matching type 'BExample<Self>' [with CompatibleType = String.CompatibleType] var bEx: BExample<Self> { ^
Goals I would like to install a specific version of Swiftlint as a dependency to my iOS project using Carthage. Currently, this works perfectly with Cocoapods: pod 'SwiftLint', '0.18.1' As result, ...
let a = [1,2] // a = [1,2] var b = a; // b = [1,2] b[1] = 3; // a = [1,3] b = [1,3] b.append(5); // a = [1,3] b = [1,3,5] b[1] = 4; // a = [1,3] b = [1,4,5]
Foo() 1(75709,0x70000aac2000) malloc: *** error for object 0x6180000129ec: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null if [ $? != 0 ] ; then # print error to STDERR echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2 exit 1 fi
I'm currently working on an objective c project where we are trying to now incorporate swift into the project. When I add a Swift unit test to the project I get the following prompt: I create the
platform :ios, '9.0' target 'XXXXX' do pod 'CorePlot', '2.2' pod 'Google-Mobile-Ads-SDK', '7.20.0' pod 'FBSDKCoreKit', '4.23.0' pod 'FBSDKLoginKit', '4.23.0' pod 'FBSDKShareKit', '4.23.0' pod 'Flurry-iOS-SDK/FlurrySDK', '8.1.0' pod 'Fabric', '1.6.11' pod 'TwitterKit', '2.8.1' pod 'TwitterCore', '2.8.0' pod 'Crashlytics', '3.8.4' pod 'SVProgressHUD', '2.1.2' pod 'Realm', '2.7.0' pod 'Repro', '2.4.0' pod 'SwiftLint', '0.19.0' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = 'NO' end end end
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null if [ $? != 0 ] ; then # print error to STDERR echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2 exit 1 fi
When I send a GET request twice with Alamofire I get the same response but I'm expecting a different one. I was wondering if it was because of the cache, and if so I'd like to know how to disable it.
New Issue Checklist Updated fastlane to the latest version I have read the Contribution Guidelines Issue Description I updated fastlane(2.11.0) to the latest version(2.23.0) by bundle update fa...
If you have enabled two-factor authentication, or if you are accessing an organization that uses SAML single sign-on, you must provide a personal access token instead of entering your password for HTTPS Git.
Via HTTPS For those checking out sources as read-only, HTTPS works best: git clone https://github.com/apple/swift.git ./swift/utils/update-checkout --clone Via SSH For those who plan on regularly making direct commits, cloning over SSH may provide a better experience (which requires uploading SSH keys to GitHub): git clone git@github.com:apple/swift.git ./swift/utils/update-checkout --clone-with-ssh
swiftのリポジトリにも、sshのほうが may provide a better experience って書いてあるけど
let image = NSImage(cgImage: cgImage, size: NSSize.zero) image.tiffRepresentation // nil
この cgImage は↓のように生成されています。
extension Image where Pixel == RGBA { public var cgImage: CGImage { let length = count * 4 // count == width * height var data = Data(capacity: length) data.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Void in // 略 } let provider: CGDataProvider = CGDataProvider(data: data as CFData)! return CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: width * 4, space: Image.colorSpace, bitmapInfo: Image.bitmapInfo, provider: provider, decode: nil, shouldInterpolate: false, intent: CGColorRenderingIntent.defaultIntent)! } fileprivate static var colorSpace: CGColorSpace { return CGColorSpaceCreateDeviceRGB() } fileprivate static var bitmapInfo: CGBitmapInfo { return CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue | CGBitmapInfo.byteOrder32Big.rawValue) } }
tiffRepresentation のドキュメントには↓のようにありますが、特に PDF や EPS のようなベクター形式の representation にはなっていないと思います。 "if the TIFF data cannot be created" の原因がわからず・・・。
If one of the receiver's image representations does not support the creation of TIFF data natively (PDF and EPS images, for example), this property creates the TIFF data from that representation's cached content. This property contains nil if the TIFF data cannot be created.
New Issue Checklist Updated SwiftLint to the latest version I searched for existing GitHub issues Rule Request In many cases, the trailing closure syntax can make code clearer by reducing boile...
私もSwift学習始めたばかりなので、この話題はとても気になります。 Swift Playgroundsって日本語対応していたかと思うのですが、これって他言語経験者も学習対象になっている感じなのでしょうか。 私はあいにくiPadを所持していないのでやったことがないのですが、これが完全初心者でなくてもかなり参考になるようなら、ここから始めてみるのもありなような気がします。
Read a free sample or buy The Swift Programming Language (Swift 4) by Apple Inc.. You can read this book with iBooks on your iPhone, iPad, iPod touch, or Mac.
Memory ownership model. An (opt-in) Cyclone/Rust-inspired memory ownership model is strongly desirable for systems programming and for other high-performance applications that require predictable and deterministic performance. Part of this model was introduced in Swift 4 when we began to enforce exclusive access to memory. In Swift 5 our goal is to tackle the pieces of the ownership model that are key to ABI stability.
pieces of the ownership model that are key to ABI stability.
前のxcodeだとlinked frameworkで入ったフレームワークを左ペインでグループにまとめるとかしてましたけど 今のバージョンだとグループ作ってD&Dで移動すると実体が移動してしまう気がしてます。(New Group, New Group without Folder問わず) 何か方法あるんでしょうか?
それぞれ別のassociatedtypeを持つprotocol A, B に適合したprotocol Cを作成した場合についての質問です。 protocol A, BそれぞれのassociatedtypeのTypeは同一なので、 struct適合時にはどちらか一つのみtypealiasを定義したいです。 しかし、protocol Cにてwhereで条件を書いても どちらか一方のprotocolに適合していないとコンパイルエラーが出てしまいます。。 この場合、何か策はあるのでしょうか?
protocol A { associatedtype TypeA } protocol B { associatedtype TypeB } protocol C: A, B where TypeA == TypeB { } struct Hoge: C { // error: type 'Hoge' does not conform to protocol 'A' typealias Type2 = String }
After you create a task, you start it by calling its resume method. The session then maintains a strong reference to the task until the request finishes or fails; you do not need to maintain a reference to the task unless it is useful to do so for your app’s internal bookkeeping purposes.
extension Image where Pixel == RGBA<UInt8> { public init(uiImage: UIImage) { #if os(iOS) || os(tvOS) if let cgImage = uiImage.cgImage { self.init(cgImage: cgImage) } else if let ciImage = uiImage.ciImage { let context = CIContext() // This `guard` can be replaced with `!` if you are sure that the `createCGImage` below never fails. guard let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else { fatalError("Failed to create a `CGImage` from an internal `CIImage` object from this `UIImage` instance: \(uiImage)") } self.init(cgImage: cgImage) } else { // This `gurad` can be replaced with `assert` if you are sure that the `size` is always equal to `.zero`. guard uiImage.size == .zero else { fatalError("The `size` of this `UIImage` instance (\(uiImage)) is not equal to `.zero` though both `cgImage` and `ciImage` of the instance are `nil`.") } self.init(width: 0, height: 0, pixels: []) } #else if let cgImage = uiImage.cgImage { self.init(cgImage: cgImage) } else { // This `gurad` can be replaced with `assert` if you are sure that the `size` is always equal to `.zero`. guard uiImage.size == .zero else { fatalError("The `size` of this `UIImage` instance (\(uiImage)) is not equal to `.zero` though `cgImage` of the instance is `nil`.") } self.init(width: 0, height: 0, pixels: []) } #endif }
#if で } else if ... { を落とすことができなくて悲しい・・・。
そして、 CoreImage 使ったことなかったんですが、↓を発見して頭を抱えてます
Initializes an image of infinite extent whose entire content is the specified color.
[omochi@omochi-iMac tt]$ cat a.swift let a: Int = 3 let b: Int = 2 print(b) [omochi@omochi-iMac tt]$ swiftlint Linting Swift files in current working directory Linting 'a.swift' (1/1) /Users/omochi/temp/tt/a.swift:1:1: error: Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'a' (identifier_name) /Users/omochi/temp/tt/a.swift:3:1: error: Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'b' (identifier_name) Done linting! Found 2 violations, 2 serious in 1 file.
In some cases, it's possible to have a Foundation object (either NSArray or NSDictionary) that produce a valid JSON. The current implementation of JSONDecoder allows decoding only from Data. This p...
Add ObjectEncoder.EncodingStrategy and ObjectDecoder.DecodingStrategy that creating strategy Add ObjectEncoder.encodingStrategies and ObjectDecoder.decodingStrategies th...
It's already 2 years of Swift and its interoperability with Objective-C as well. When app extensions were released we've got a way to share our code across targets using frameworks. I used to build lots of frameworks since then, sometimes I even worked full-time just on frameworks. But as I
struct Card { enum Suit { case spade case heart case club case diamond } enum Rank { case one case two case three case four case five case six case seven case eight case nine case ten case j case q case k } let suit: Suit = .heart let rank: Rank = .j init(suit: Suit, rank: Rank) {} } let card = Card(suit: .spade, rank: .k)
// Stored property. var p1: Int = 1 // Computed property. var p2 Int { get { return 1 } set { /* ... */ } } // Computed property ( 暗黙のgetのみ ) var p3: Int { return 1 }
public subscript(key: String, nested nested: Bool, ignoreNil ignoreNil: Bool) -> Map { // save key and value associated to it currentKey = key keyIsNested = nested // check if a value exists for the current key // do this pre-check for performance reasons if nested == false { let object = JSONDictionary[key] let isNSNull = object is NSNull print(object) isKeyPresent = isNSNull ? true : object != nil currentValue = isNSNull ? nil : object } else { // break down the components of the key that are separated by . (isKeyPresent, currentValue) = valueFor(ArraySlice(key.componentsSeparatedByString(".")), dictionary: JSONDictionary) } // update isKeyPresent if ignoreNil is true if ignoreNil && currentValue == nil { isKeyPresent = false } return self }
I’ve been submitting my app to the App Store for test flight and after build 11, I’ve been getting failures via email from Apple: Non-public API usage: The app contains one or more corrupted binar...
Read a free sample or buy The Swift Programming Language (Swift 4.1 beta) by Apple Inc.. You can read this book with iBooks on your iPhone, iPad, iPod touch, or Mac.
- Added the Conditionally Conforming to a Protocol section with information about conditional protocol conformance. - Added information about recursive protocol constraints to the Using a Protocol in Its Associated Type’s Constraints section. - Added information about the canImport() and targetEnvironment() platform conditions to Conditional Compilation Block.
SpreadsheetView - Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if y...
Even if an optional constraint cannot be satisfied, it can still influence the layout. If there is any ambiguity in the layout after skipping the constraint, the system selects the solution that comes closest to the constraint. In this way, unsatisfied optional constraints act as a force pulling views towards them.
objc[29923]: Class _TtC8Dispatch16DispatchWorkItem is implemented in both /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftDispatch.dylib (0x1018f7530) and /Users/taketo1024/Library/Developer/Xcode/DerivedData/TimeProfile-aryrvmqtlkmqgqbautymimyzbktk/Build/Products/Debug/TimeProfile (0x1005c6820). One of the two will be used. Which one is undefined.
@taketo1024 Command Line Toolはバンドルを持てないので、DynamicFrameworkを自身に持つことはできないところを、Run Pathを変更してリンクできるようにしているという状況ですね。でSwift Standard LibraryがSwiftyAlgebraとTimeProfileのそれぞれにStatic LinkしているのでDuplicatedということです。
1
とりあえず問題の切り分けのために TimeProfileターゲットでSWIFT_FORCE_DYNAMIC_LINK_STDLIB=YESとSWIFT_FORCE_STATIC_LINK_STDLIB=NOをUser Defined Settingで追加してみてください。
で、プロファイルを取りたいということで配布したいというわけじゃなさそうなので上記の方法でもまあいいと思うんですけど、基本的にはCommand Line ToolじゃなくてMac AppにしてそれにDynamicLinkする形で使う方が素直な挙動になります。
上の説明、正しくないですね。正確にはCommand Line Toolはバンドルを持てないのでSwiftの「標準ライブラリ」をバンドルに含むことができなくて、SwiftyAlgebraが標準ライブラリを参照しようとして見つからないのが最初のエラー。rpathをXcodeの/usr/libに向けてSwiftyAlgebraが標準ライブラリを見つけられるようにしたのが佐野さんの対処で、それだと動くけどCommand Line Toolに静的リンクされている標準ライブラリと衝突するのでそのエラーのログが出てしまうという状態(移植性も失われる)。
protocol A where Y.X == Self, Y.Z == Z { // Redundant same-type constraint 'Self.Z' == 'Self.Y.Z' associatedtype Y: B associatedtype Z } protocol B where X.Y == Self, X.Z == Z { // Redundant same-type constraint 'Self.Z' == 'Self.X.Z' associatedtype X: A associatedtype Z } struct AA: A { typealias Y = BB typealias Z = Int } struct BB: B { typealias X = AA typealias Z = String // !? }
takasek/XCJumpToTests: the Xcode Source Editor Extension / AppleScript to jump files of Implementation⇄Tests https://github.com/takasek/XCJumpToTests こちらのAppleScriptを改変したら目的は達成出来ましたm()m(edited)
protocol ViewProtocol: class { associatedtype Presenter: PresenterProtocol var presenter: Presenter! { get } } protocol PresenterProtocol: class { associatedtype View: ViewProtocol weak var view: View? { get } }
protocol A where Y.X == Self, Y.Z == Z { // Redundant same-type constraint 'Self.Z' == 'Self.Y.Z' associatedtype Y: B associatedtype Z } protocol B where X.Y == Self, X.Z == Z { // Redundant same-type constraint 'Self.Z' == 'Self.X.Z' associatedtype X: A associatedtype Z } struct AA: A { typealias Y = BB typealias Z = Int } struct BB: B { typealias X = AA typealias Z = String // !? }
struct A { var name = "a" } print(A()) struct B { var name = "b" } extension B: CustomDebugStringConvertible { var debugDescription: String { return "{\(name)}" } } print(B())
4> let a = A() a: A = { name = "a" } 5> struct B { 6. var name = "b" 7. } 8. 9. extension B: CustomDebugStringConvertible { 10. 11. var debugDescription: String { 12. return "{\(name)}" 13. } 14. } 15> let b = B() b: B = { name = "b" }
When using Swift REPL, every time I assign a value to a variable, it displays a whole dump of the value. I want to suppress this, because when it is an instance of a large struct, it completely blo...
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } guard 1 == 0 else { hoge() } print("離脱してないよー")
Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) * frame #0: 0x00007fffaba7aa9b libobjc.A.dylib`_objc_msgSend_uncached + 11 frame #1: 0x00007fff9865d231 Foundation`-[NSPlaceholderString initWithString:] + 107 frame #2: 0x000000010c5d4007 PlaygroundLogger`function signature specialization <Arg[0] = Dead> of static PlaygroundLogger.LoggingPolicyStack.get() -> PlaygroundLogger.LoggingPolicyStack + 151 frame #3: 0x000000010c5cdf22 PlaygroundLogger`function signature specialization <Arg[1] = Owned To Guaranteed and Exploded> of playground_log_hidden + 98 frame #4: 0x000000010c5cd65b PlaygroundLogger`playground_log_hidden + 27 frame #5: 0x000000010c5fc094 $__lldb_expr82`hoge() at MyPlayground.playground:2
コンパイルは通って実行時に死んだ
unsafeBitCast((), to: Never.self) これでNever型のインスタンス作れるの @kateinoigakukun が気づいた
The Swift type-checker remains a performance bottleneck for compile times, though it has improved tremendously over the past two years. You could even say the type-checker has gone from being drunk to sober. To help users debug these issues, awhi...
I just created one new cordova ios project via CLI, and i opened that project in Xcode 7.1 and while running on simulator am getting some error on mainViewController.xib, if we clicked on that erro...
このサイトの1番上の答えを翻訳しながら行ったのですが、trash it. で、どれをどう消せばいいかわからないです。下の追記みたいな所にファイル自体は消すなって書いてあることはわかるんですが、、、
$ carthage update --platform ios *** Fetching GPUImage *** Checking out GPUImage at "0.1.7" *** xcodebuild output can be found in /var/folders/62/nrp34pc96t550_hhml86hmwrr_q2rc/T/carthage-xcodebuild.MYLmCm.log *** Building scheme "GPUImageFramework" in GPUImage.xcodeproj Failed to write to /Users/snakagam/Desktop/MyLibrary/Carthage/Build/iOS/GPUImage.framework: Error Domain=NSCocoaErrorDomain Code=260 "The file “GPUImage.framework” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/snakagam/Desktop/MyLibrary/Carthage/Checkouts/GPUImage/build/ArchiveIntermediates/GPUImageFramework/BuildProductsPath/Release-iphoneos/GPUImage.framework, NSFilePath=/Users/snakagam/Desktop/MyLibrary/Carthage/Checkouts/GPUImage/build/ArchiveIntermediates/GPUImageFramework/BuildProductsPath/Release-iphoneos/GPUImage.framework, NSUnderlyingError=0x7f870a806a90 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
*** Cloning GPUImage *** Checking out GPUImage at "0.1.10" *** xcodebuild output can be found in /var/folders/62/nrp34pc96t550_hhml86hmwrr_q2rc/T/carthage-xcodebuild.5AWMmm.log *** Building scheme "GPUImageFramework" in GPUImage.xcodeproj Failed to write to /Users/snakagam/Desktop/MyLibrary/Carthage/Build/iOS/GPUImage.framework: Error Domain=NSCocoaErrorDomain Code=260 "The file “GPUImage.framework” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/snakagam/Desktop/MyLibrary/Carthage/Checkouts/GPUImage/framework/build/ArchiveIntermediates/GPUImageFramework/BuildProductsPath/Release-iphoneos/GPUImage.framework, NSFilePath=/Users/snakagam/Desktop/MyLibrary/Carthage/Checkouts/GPUImage/framework/build/ArchiveIntermediates/GPUImageFramework/BuildProductsPath/Release-iphoneos/GPUImage.framework, NSUnderlyingError=0x7fa56e662420 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
folding-cell - :octocat: FoldingCell is an expanding content cell with animation inspired by folding paper card material design. Swift UI Library by @Ramotion
folding-cell - :octocat: FoldingCell is an expanding content cell with animation inspired by folding paper card material design. Swift UI Library by @Ramotion
public protocol IntModuleObjectType: ModuleObjectType where R == 𝐙 { ... } extension ModuleObject: IntModuleObjectType where R == 𝐙 {}
この 297 行目でコメントアウトしてる部分を外すと、 100 行目で
Binary operator '==' cannot be applied to operands of type '_Matrix<Dynamic, Dynamic, R>' and '_Matrix<Dynamic, Dynamic, ModuleObject.R>' (aka '_Matrix<Dynamic, Dynamic, Int>')
1. While running pass #509 SILModuleTransform "Mandatory Inlining of Transparent Functions". <unknown>:0: error: unable to execute command: Abort trap: 6 <unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
$ docker run --privileged -it -v `pwd`:`pwd` -w `pwd` --rm norionomura/swift:swift-4.2-branch swift test Compile Swift Module 'SwiftyMath' (70 sources) /Users/norio/github/SwiftyMath/Sources/SwiftyMath/Matrix/SquareMatrix.swift:18:1: error: conditional conformance of type '_Matrix<n, m, R>' to protocol 'Ring' does not imply conformance to inherited protocol 'Monoid' extension SquareMatrix: Ring where n == m { ^ /Users/norio/github/SwiftyMath/Sources/SwiftyMath/Matrix/SquareMatrix.swift:18:1: note: did you mean to explicitly state the conformance like 'extension _Matrix: Monoid where ...'? extension SquareMatrix: Ring where n == m { ^ error: terminated(1): /usr/bin/swift-build-tool -f /Users/norio/github/SwiftyMath/.build/debug.yaml test output:
Use an unowned reference only when you are sure that the reference always refers to an instance that has not been deallocated. If you try to access the value of an unowned reference after that instance has been deallocated, you’ll get a runtime error.
$ cat unowned.swift class A {} class B { unowned let a: A init(a: A) { self.a = a } } let b = B(a: A()) print(b.a) $ swift -Ounchecked unowned.swift unowned.A
This was part of the original weak design that there was never any particular reason to rush the implementation for. It's convenient to do this now so that we can use it to implement Unmanaged...
Hi, I’d like to propose to deprecate the -Ounchecked swift optimization mode. The -Ounchecked mode actually contradicts one of the main goals of swift: to be a safe language. In the past we didn’t see lot of significant performance differences compared to -O (there wer...
Hi, I’d like to propose to deprecate the -Ounchecked swift optimization mode. The -Ounchecked mode actually contradicts one of the main goals of swift: to be a safe language. In the past we didn’t see lot of significant performance differences compared to -O (there wer...
あったわ
同じだ。
Hi, I’d like to propose to deprecate the -Ounchecked swift optimization mode.
struct Foo: Codable { private enum CodingKeys: CodingKey { case a } var a: Int private var _b: String }
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: type 'Foo' does not conform to protocol 'Decodable' struct Foo: Codable { ^ Swift.Decodable:2:12: note: protocol requires initializer 'init(from:)' with type 'Decodable' public init(from decoder: Decoder) throws ^ /usercode/main.swift:6:17: note: cannot automatically synthesize 'Decodable' because '_b' does not have a matching CodingKey and does not have a default value private var _b: String ^
前にも聞いた気がするんですけど(履歴検索してもうまくひっかからなかったので)、これってどこかに仕様として明記されてましたっけ? Array の API リファレンスも The Swift Programming Language にも書かれてなさそう( thread で検索してみただけだけど)。標準ライブラリのコードから実態としてスレッドセーフじゃないということでしょうか?
(edited)
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
The most important consequence of this is that two different array elements cannot be simultaneously accessed. This will interfere with certain common idioms for working with arrays, although some cases (like concurrently modifying different slices of an array) are already quite problematic in Swift.
import Foundation let semaphore = DispatchSemaphore(value: 0) var array = [Int]() DispatchQueue.global().async { for i in 0...1000 { array.append(i) } print("end 1") } DispatchQueue.global().async { for i in 0...1000 { array.append(i) } print("end 2") } DispatchQueue.global().async { for i in 0...1000 { array.append(i) } print("end 3") } semaphore.wait()
import Foundation var array = Array(repeating: 1, count: 100000) DispatchQueue.global().async { array.insert(3, at: 99999) print("inserted") } print("start") let total = array.reduce(0) { t, c in if t % 100 == 0 { print(".", terminator: "") } return t + c } print("") print(total) print(array.count)
「The project "プロジェクト名‘’ is damaged and cannot be opened due to a parse error. Examine the project file for invalid edits or unresolved source control conflicts. Path: /Users/自分の名前/Code/iOSapps/プロジェクト/プロジェクト名.xcodeproj」 ローカルでmasterとマージさせた後xcodeproj/project.pbxprojのコンフリクトを解消して、いざプロジェクトを開こうとすると上記エラーを吐くのですが、どう解決すればよろしいでしょうか???
おもしろいですね。 問題を整理すると、 a, b は型が Array<Int> に確定しているので、 if a == b {} は問題ないのですが、 リテラルを直接書いた場合( if [1] == [1] {} )は、 演算子 == リテラルをどの型として評価すべきか1つに定まらないから、ですね。 ちなみに問題は == に配列リテラルを渡したときに、配列リテラルからインスタンスできる型が複数あるからですね。(IndexzSetとIndexPath?) 例えばFoundationをImportしなければそれは存在しないので、上記のコードもコンパイルできます。(edited)
$ swift test -c release [3/3] Linking ./.build/x86_64-apple-macosx/release/memory-crash-testPackageTe… Test Suite 'All tests' started at 2019-03-29 18:38:34.556 Test Suite 'memory-crash-testPackageTests.xctest' started at 2019-03-29 18:38:34.556 Test Suite 'memory_crash_testTests' started at 2019-03-29 18:38:34.556 Test Case '-[memory_crash_testTests.memory_crash_testTests testExample]' started. broadcast: start broadcast: end will exit testExample Exited with signal code 11
誰かなにか分かりませんでしょうか? 環境
$ swift --version Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3) Target: x86_64-apple-darwin18.5.0 $ swift package --version Apple Swift Package Manager - Swift 5.0.0 (swiftpm-14490.60.2)
There is no sliver bullet in the architecture, each of them has weakness and strength. If you want to know more information about each architecture, you can check this book, https://www.objc.io/books/app-architecture/(edited)
public protocol AppConfigProvider: NSObject { var config: AppConfig { get set } } // MARK : - Rx properties extension Reactive where Base: AppConfigProvider { /// Reactive wrapper for `config` property. public var config: Observable<AppConfig?> { return base.rx.observe(AppConfig.self, "config") } }
// Type Erasure public class AnyAppConfigProvider : NSObject, AppConfigProvider { public var config: AppConfig { get { return base.config } set { base.config = newValue } } private let base: AppConfigProvider public init<X: AppConfigProvider>(_ base: X) { self.base = base } } // 実際の具体的なAppConfigProvider public class ACP : NSObject, AppConfigProvider { public var config: AppConfig public init(config: AppConfig) { self.config = config } } // 利用時 var a: AnyAppConfigProvider = AnyAppConfigProvider(ACP(config: AppConfig())) print(a.rx.config)
public protocol AppConfigProvider { var config: AppConfig { get set } var rx_config: Observable<AppConfig> { get } } public class ACP : AppConfigProvider { public var configSubject: PublishSubject<AppConfig> public var config: AppConfig { return try! configSubject.value()} public var rx_config: Observable<AppConfig> { return configSubject } }
<stdin>:39:21: error: protocol type 'AppConfigProvider' cannot conform to 'AppConfigProvider' because only concrete types can conform to protocols _ = provider.rx.config ^
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<App.AppEnvironment 0x282777d20> addObserver:<_TtC7RxCocoaP33_F7515DBB13B60709A3CB25DD19EDD11D11KVOObserver 0x280d28690> forKeyPath:@"config" options:5 context:0x0] was sent to an object that is not KVC-compliant for the "config" property.'
ただつけるだけだと下記のエラーが出てしまいますが、そんな気がします・・・! @objc can only be used with members of classes, @objc protocols, and concrete extensions of classes
public protocol AppConfigProvider: NSObject { @objc var config: AppConfig { get set } var rx_config: Observable<AppConfig> { get } }
しかし @objc protocolにしてみると Property cannot be a member of an @objc protocol because its type cannot be represented in Objective-Cや Protocol 'AppConfigProvider' is '@objc' and cannot have a superclass constraint が出てしまいます。
public @objc protocol AppConfigProvider: NSObject { var config: AppConfig { get set } var rx_config: Observable<AppConfig> { get } }
public final class AppConfig: NSObject { public init() {} } @objc public protocol AppConfigProvider: NSObjectProtocol { @objc var config: AppConfig { get set } } extension AppConfigProvider { var rxoriginal: Reactive<AppConfigProvider> { return Reactive(self) } } extension Reactive where Base: AppConfigProvider { var config: Observable<AppConfig?> { return (base as! NSObject).rx.observe(AppConfig.self, "config") } }
protocol AppConfigProvider { var rx: RxEnvironmentProvider { get } var config: AppConfig { get set } } protocol RxAppConfigProvider { var config: Observable<AppConfig> { get } } final class AppEnvironment: AppConfigProvider { private var rx: RxAppEnvironment var config: AppConfig { get { return try! configSubject.value() } set { rx.configSubject.onNext(newValue) } } } struct RxAppEnvironment: RxAppConfigProvider { let configSubject: BehaviorSubject<Entity.AppConfig> var config: Observable<AppConfig> { return configSubject } }
Recently I downloaded Xcode 9 and created one sample iPhone app but the app is not able to build as it shows the following error: ld: entry point (_main) undefined. for architecture x86_64 I se...
workspace 'App.xcworkspace' project 'Sources/App/App.xcodeproj' target 'App' do use_frameworks! pod 'Firebase/Core' pod 'Fabric', '~> 1.10.0' pod 'Crashlytics', '~> 3.13.0' target 'AppTests' do inherit! :search_paths end end
workspace 'App.xcworkspace' target 'App' do project 'Sources/App/App.xcodeproj' use_frameworks! install_pods target 'AppTests' do inherit! :search_paths end end target 'Feature1' do project 'Sources/Features/Feature1/Feature1.xcodeproj' install_pods target 'Feature1Tests' do inherit! :search_paths end end def install_pods use_frameworks! pod 'Firebase/Core' pod 'Fabric', '~> 1.10.0' pod 'Crashlytics', '~> 3.13.0' end
If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack.
The review of SE-0253: Static callables begins now and runs through April 5, 2019. Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to me as t...
var a = Array(repeating: 0, count: 10) let group = DispatchGroup() group.enter() for i in a.indices { DispatchQueue.global().async { a[i] = i group.leave() // EXC_BAD_INSTRUCTION } } group.wait() print(a) // [0, 1, ..., 9] と出て欲しい
var a = Array(repeating: 0, count: 10) let q = DispatchQueue(label: "array") let group = DispatchGroup() group.enter() for _i in a.indices { let i = _i DispatchQueue.global().async { q.sync { a[i] = i } group.leave() // EXC_BAD_INSTRUCTION } } group.wait() print(a) // [0, 1, ..., 9] と出て欲しい
var a = Array(repeating: 0, count: 10) let b = Array(0 ..< 10) let q = DispatchQueue(label: "array") DispatchQueue.concurrentPerform(iterations: 10) { i in let x = b[i] * 2 q.sync { a[i] = x } }
Parameterized Extensions Proposal: SE-NNNN Author: Alejandro Alonso Review Manager: TBD Status: Awaiting Review Implementation: apple/swift#25263 Introduction Hello Evolution, this is my first draft at a proposal for Parameterized Extensions. I would greatly appreciate ...
1> import Python 2> let numpy = Python.import("numpy") error: repl.swift:2:13: error: module 'Python' has no member named 'import' let numpy = Python.import("numpy") ^~~~~~ ~~~~~~
$ DEVELOPER_DIR=/Applications/Xcode-beta.app swift -frontend -repl -sdk $(DEVELOPER_DIR=/Applications/Xcode-beta.app xcrun -sdk macosx -show-sdk-path) *** You are running Swift's integrated REPL, *** *** intended for compiler and stdlib *** *** development and testing purposes only. *** *** The full REPL is built as part of LLDB. *** *** Type ':help' for assistance. *** (swift)
file:///Users/otoyamisato/Mydictionary/MyDictionary/Base.lproj/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for NewNoteViewController (iIJ-cw-XLr): Failed to launch designables agent. Check the console for a more detailed description and please file a bug report at bugreport.apple.com.
In file included from /home/taketo1024/ClosedRegion/Sources/LinBoxWrapper/LinBoxWrapper.mm:8: In file included from /home/taketo1024/ClosedRegion/Sources/LinBoxWrapper/include/LinBoxWrapper.h:8: In file included from /usr/include/GNUstep/Foundation/Foundation.h:30: /usr/include/GNUstep/GNUstepBase/GSVersionMacros.h:361:16: fatal error: 'objc/blocks_runtime.h' file not found # include <objc/blocks_runtime.h> ^~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.
A tiny shell script for installing GNUstep and libobjc2 automatically on Ubuntu 12. I recommend that you download this script to a distinct folder "gnustep-installer". It will dow...
としたら求める形にできたのですが,Pointer is missing a nullability type specifier という警告がたくさん出てしまいました。 NS_ASSUME_NONNULL_BEGIN ... END で囲めば消せるようなのですが、これを使うには Foundation を import する必要があるらしいんですが、それ以外の方法はあるでしょうか?(Linux で動かしたいので Foundation free にしたい)
When we were discussing the Charter of the SSWG last year, one area several people mentioned they were interested in collaborating on is improving the experience of deploying Swift applications and managing them at scale. A critical part of that is ensuring that Swift has a ...
This article provides cross-platform functions to get the peak (maximum) and current resident set size of a process, and explains what works on what OS.
public class SynchronizedDictionary<Key: Hashable, Value> { private var dictionary: [Key: Value] = [:] private let queue = DispatchQueue(label: "hoge", qos: .default, attributes: .concurrent) public subscript(_ key: Key) -> Value? { get { queue.sync { dictionary[key] } } set { queue.async(flags: .barrier) { self.dictionary[key] = newValue } } } } var a = SynchronizedDictionary<Int, Int>() let n = 100000 DispatchQueue.concurrentPerform(iterations: n) { i in a[i] = i } print(a[n-1])
public class SynchronizedDictionary<Key: Hashable, Value> { private var dictionary: [Key: Value] = [:] private let queue = DispatchQueue(label: "shit", qos: .default) public subscript(_ key: Key) -> Value? { get { queue.sync { dictionary[key] } } set { queue.sync { self.dictionary[key] = newValue } } } } var a = SynchronizedDictionary<Int, Int>() let n = 100000 DispatchQueue.concurrentPerform(iterations: n) { i in a[i] = i }
Work items submitted prior to the barrier execute to completion, at which point the barrier work item executes. Once the barrier work item finishes, the queue returns to scheduling work items that were submitted after the barrier.
public class SynchronizedDictionary<Key: Hashable, Value> { private var dictionary: [Key: Value] = [:] private let queue = DispatchQueue(label: "shit", qos: .default, attributes: .concurrent) public subscript(_ key: Key) -> Value? { get { queue.sync { dictionary[key] } } set { queue.async(flags: .barrier) { [weak self] in self?.dictionary[key] = newValue } } } } var a = SynchronizedDictionary<Int, Int>() let n = 100000 DispatchQueue.concurrentPerform(iterations: n) { i in a[i] = i } print("HELLO?") print(a[n-1])
var a = ContiguousArray(repeating: 1, count: 10) a.withUnsafeMutableBufferPointer { buff in for i in 3 ..< 6 { buff[i] *= 2 // 問題なし } } a.withUnsafeMutableBufferPointer { buff in var sub = buff[3 ..< 6] for i in 0 ..< sub.count { sub[i] *= 2 // EXC_BAD_ACCESS } }
This review ended on October 21st, but because of the LLVM conference, the Core Team didn't have an opportunity to discuss it until last week. Swift's indexing model is based on solid concepts that have held up well over the years, but the verbosity of expressing positions a...
ld: warning: Could not find or use auto-linked library 'swiftDarwin' ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation' ld: warning: Could not find or use auto-linked library 'swiftObjectiveC' ld: warning: Could not find or use auto-linked library 'swiftDispatch' ld: warning: Could not find or use auto-linked library 'swiftCoreImage' ld: warning: Could not find or use auto-linked library 'swiftQuartzCore' ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics' ld: warning: Could not find or use auto-linked library 'swiftCore' ld: warning: Could not find or use auto-linked library 'swiftMetal' ld: warning: Could not find or use auto-linked library 'swiftFoundation'
Swift & SwiftUIを初めて触り SwiftUIのチュートリアルをやっていて不明な点があったので質問させてください! 質問: 以下のcategories, featured の変数宣言の仕方が複雑でどうなってるのでしょうか?宣言時にクロージャをつけると代入になる模様です。いまいち仕組みがわかりません、、 解説もしくは何かリファレンスになるリンクを頂けると嬉しいです。
struct CategoryHome: View { var categories: [String: [Landmark]] { get { return Dictionary( grouping: landmarkData, by: { $0.category.rawValue } ) } } var featured: [Landmark] { get { return landmarkData.filter { $0.isFeatured } } } ... }
^ 省略されている部分を書き足しました。
このcategories, featured はComputed Propertyと呼ばれるもので、Property(プロパティ、メンバ変数、インスタンス変数)の一種ですが、実際の値を変数に保持しているわけではなく、アクセスがあったときに書かれている処理を実行して動的に値を返すことができる、というものです。
利用側は
let home = CategoryHome() let categories = home.categories
このように通常のプロパティと同じようにアクセスしますが、 Computed Propertyはアクセスされたときに書かれている処理(ここでは get { ... } の中カッコの部分)を実行して値を返します。
詳しくは先のリンクのドキュメントを見ると良いですが、 Computed Propertyはget と set の両方を定義できて、この例ではget の場合だけが定義されています。(edited)
はじめまして。 Xcodeプロジェクトから出力した.frameworkをiOS開発のプロジェクトに埋め込むことができず困っています。 「iOSアプリ設計パターン」という本のサンプルコード をGitHubからダウンロードし、「GitHub.xcodeproj」を開き、特に設定は変更せずにそのままビルドしました。 出来上がった「Github.framework」をMedia ▸ アプリケーション ▸ Xcode ▸ Contents ▸ Developer ▸ Platforms ▸ iPhoneOS.platform ▸ Developer ▸ SDKs ▸ iPhoneOS.sdk ▸ System ▸ Library ▸ Frameworksに配置しました。 このGithub.frameworkを使用したいプロジェクトをXcodeで開き、プロジェクトのGeneral → Framework, Libraries and Embedded codeにGithub.frameworkを追加しました ビルドすると、以下のエラーが出ました GitHub is not available when building for iOS Simulator. Consider using #if os(iOS) to conditionally import this framework when building for iOS. No such module 'GitHub' Xcodeを使ってライブラリをリンクさせたことがありませんので、何か基本的な事を間違えているのだと思いますが、どなたか教えていただけると幸いです。
SwiftUIを勉強中なのですが、「Unable to infer complex closure return type; add explicit type to disambiguate」というエラー文が解決できずに躓いています。このエラー文はどういったときに出るものなのか、教えていただけると助かります。
When I click on the cell to open the MPMediaPickerController it opens when it starts up. class MediaViewController: UITableViewController, MPMediaPickerControllerDelegate override func tableView(_
iOS 13では、アプリによるバックグラウンドでのVoIP(Vioce over Internet Protocol)が使えなくなります。たとえばこの機能を利用しているFacebookのMessengerやWhatsAppといったアプリに影響が出ることが予想されます。 米ニュースメディアThe Informati...
質問です。 EnvironmentObjectで作成した配列をForm内のPickerで選択できるようにしたいのですが、動作がうまくいきません。 シミュレータで動かそうとすると、エラーが起きてしまいます。 エラー文 '''Thread 1: Fatal error: No ObservableObject of type HistoryEntity found. A View.environmentObject(_:) for HistoryEntity may be missing as an ancestor of this view.''' コード
//Data.swift import SwiftUI import Combine class HistoryEntity: ObservableObject{ @Published var UserName:[String] = [] } //AddView.swift @EnvironmentObject var histroy: HistoryEntity var body: some View { NavigationView { Form { Picker(selection: $Selection, label: Text("name")) { ForEach(0..<histroy.UserName.count){ Text(self.histroy.UserName[$0]) } } } }
Thread 1: Fatal error: No ObservableObject of type HistoryEntity found. A View.environmentObject(_:) for HistoryEntity may be missing as an ancestor of this view.'''
I'm building an app with SwiftUI. When I was trying to display a sheet (previously Modal), this error message appears: Thread 1: Fatal error: No observable object of type
質問させてください。 SwiftUIでCoreDataに["A","B","C"]のような文字配列を保存したいのですが、やり方がわかりません。 一応解答らしき記事を見つけはしたのですが、なかなか解読できずにいます。 https://stackoverflow.com/questions/29825604/how-to-save-array-to-coredata 「If keeping it simple and store an array as a string」あたりだと思うのですが、 ・このコードをどこに書けばいいのか ・「xcdatamodel」でどの型を宣言すればいいのか 教えていただけると助かります。
I need to save my array to Core Data. let array = [8, 17.7, 18, 21, 0, 0, 34] The values inside that array, and the number of values are variable. 1. What do I declare inside my NSManagedObject...
How do I initialize an Array in swift with a specific capacity? I've tried: var grid = Array <Square> () grid.reserveCapacity(16) but get the error expected declaration
僕は Core Data を使ったことがないですが、何かの値をキーにして検索するというのはごく基本的な操作ですので、 Core Data の使い方を検索すればすぐに情報が出てきそうに思います。 FSCalendar と組み合わせて検索すると一気に情報が減るでしょうが、 Core Data 単独であればいくらでもありそうかと。
ただ、 tarunon さんの言うように、 - オブジェクト指向の基礎 を身に付けることも必要ですし、↑のコードを理解するには - Swift の基本構文や標準ライブラリの基礎(たとえば、↑のコードの try や as! の意味は? fatalError で何が起こる? fatalError の戻り値の型の Never とは?どういうケースで will never be executed の警告が出るか) - Core Data の基礎 - NSPredicate (これ自体は Core Data とは独立に Foundation に存在します) についての知識も必要になります。
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x105a060c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key videoPreview.' terminating with uncaught exception of type NSException
Possible solution at the end. I am developing a UIViewController with three UITextField. The function to open the keyboard when the screen is presented was working for 3 years non-stop, then after...
Swift 勉強しようと思い、手元にあるURLリスト(1,000 ドメインくらい) をクローリングするコードを書いて見たのですが、数件取得したのちに A server with the specified hostname could not be found のようにエラーが出てしまい、curl ではアクセスできるURLでもうまくクローリングできません。 何かネットワークの設定などが必要でしょうか? https://gist.github.com/dictav/52e180d8f449912a0c8fe77d53f61b1c URLSession を使っています。
session.dataTask(with: URLRequest(url: self.url)) { (data, response, error) in defer { self.isExecuting = false self.isFinished = true } if let err = error { print(self.url, err.localizedDescription) return } if let res = response as? HTTPURLResponse { print("status: \(res.statusCode)") } }.resume()
There has been a ton of debate on the swift-evolution mailing lists about access control in Swift. A couple of days ago, the proposal SE-0159: Fix Private Access Levels was rejected. I want to share my thoughts on this, as...
・App Tracking Transparency対応とは、今まではユーザーの許可無くIdentifier for Advertisersを 取得出来ていたが、iOS14.5以降は、Identifier for Advertisersを取得するためには ユーザーの許可が必要になったと言う認識で合ってますでしょうか?
import Dispatch var targets = Set(0 ..< 10000) var results: [Int: Int] = [:] let atomic = DispatchQueue(label: "atomic", qos: .userInteractive) DispatchQueue.concurrentPerform(iterations: 4) { _ in // create local copy var localResults = atomic.sync { results } while true { let next = atomic.sync { targets.popFirst() } guard let i = next else { break // all targets popped, exit loop. } if let result = find(in: i, currentResults: localResults) { atomic.sync { // update results if not updated by other threads. if localResults.count == results.count { results[i] = result } else { // otherwise retry i. targets.insert(i) } } } atomic.sync { // update local copy if necessary if localResults.count != results.count { localResults = results } } } } // parallelized function func find(in i: Int, currentResults: [Int: Int]) -> Int? { i % 100 == 0 ? i : nil } print(results.count)
import Dispatch var targets = Set(0 ..< 10000) var results: [Int: Int] = [:] let atomic = DispatchQueue(label: "atomic", qos: .userInteractive) DispatchQueue.concurrentPerform(iterations: 4) { _ in // create local copy var localResults = atomic.sync { results } while true { let next = atomic.sync { targets.popFirst() } guard let i = next else { break // all targets popped, exit loop. } if let result = find(in: i, currentResults: localResults) { atomic.sync { // update results if not updated by other threads. if localResults.count == results.count { results[i] = result } else { // otherwise retry i. targets.insert(i) } } } atomic.sync { // update local copy if necessary if localResults.count != results.count { localResults = results } } } } // parallelized function func find(in i: Int, currentResults: [Int: Int]) -> Int? { i % 100 == 0 ? i : nil } print(results.count)
利用している C++ 製ライブラリ(Eigen)が OMP という並列計算のためのライブラリをサポートしていて,これを有効にしたいと思って色々やっています.こちらにある方法を参考に, OpenMP on High Sierra https://iscinumpy.gitlab.io/post/omp-on-high-sierra/brew install libomp した上で,Package.swift を次のように書くと:
ld: warning: ignoring file /usr/local/opt/libomp/lib//libomp.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 Undefined symbols for architecture arm64: "___kmpc_fork_call", referenced from: ...
I think there is currently no solution for this, since the release configuration implies ONLY_ACTIVE_ARCH set to false for packages which means they will always build for all supported architectures.
I have a MacBook M1 and have installed a library on my machine that was compiled for an x86 / Intel architecture. I have some source code that uses OpenMP. I would like to compile my code and li...
You can also use OpenMP with Apple Clang and Homebrew libomp (brew install libomp). Just replace a command like clang -fopenmp test.c with clang -Xpreprocessor -fopenmp test.c -lomp.
<stdin>:3:15: error: immutable value 'x' may only be initialized once async let x = 42 // Immutable value 'x' may only be initialized once ^ <stdin>:3:19: note: initial value already provided in 'let' declaration async let x = 42 // Immutable value 'x' may only be initialized once ^ <stdin>:3:15: note: change 'let' to 'var' to make it mutable async let x = 42 // Immutable value 'x' may only be initialized once ^~~ var
<stdin>:5:9: error: expression is 'async' but is not marked with 'await' print(x) ^~~~~~~~ await <stdin>:5:15: note: reference to async let 'x' is 'async' print(x) ^
<stdin>:4:15: error: immutable value 'x' may only be initialized once async let x = foo() ^ <stdin>:4:19: note: initial value already provided in 'let' declaration async let x = foo() ^ <stdin>:4:15: note: change 'let' to 'var' to make it mutable async let x = foo() ^~~ var
Ensan
ありがとうございます。ただ、以下のコードは動いていて、2回await xを書くとエラーになります。
struct Test { func test() async { async let x = 42 print(await x) } }
<stdin>:6:15: error: immutable value 'l' may only be initialized once async let (l, r) = (left(), right()) ^ <stdin>:6:20: note: initial value already provided in 'let' declaration async let (l, r) = (left(), right()) ^ <stdin>:6:15: note: change 'let' to 'var' to make it mutable async let (l, r) = (left(), right()) ^~~ var <stdin>:6:15: error: immutable value 'r' may only be initialized once async let (l, r) = (left(), right()) ^ <stdin>:6:23: note: initial value already provided in 'let' declaration async let (l, r) = (left(), right()) ^ <stdin>:6:15: note: change 'let' to 'var' to make it mutable async let (l, r) = (left(), right()) ^~~ var
Xcode13 beta5でApp Storeに提出しようとすると、Validationで「App Store Connect Operation Error: Unable to process app at this time due to a general error」と言われて失敗するのですが、同じ症状の方いますか?
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. - GitHub - twitter/TwitterTextEditor: A standalone, flexible API that provides a full-featured rich t...
First, I know macOS Monterey is still beta. But this problem started after Monterey beta 2 21A5268h (beta 1 21A5248p works), and Apple has been released RC2, so posted (share) this issue. Note that...
Montereyのメモリアロケーションでこの辺のアドレスを予約して使うようになってみたいですね たまたま、TSAN が Go 言語用に予約していたアドレス帯と被ったようです (edited)
go test -race で race detection を有効にしてテストを走らせることができるのですが、Monterey になってから -race 付けた時だけクラッシュするようになりました。ぼくはこの辺詳しくないですが、 go test -race が LLVM の TSAN を使っていたようです。(edited)
Issue close #223 close #260 Overview Replace completion handler with Swift Concurrency. Checklist Format code with SwiftLint (⌘B in Xcode) Resolve Xcode warning What to check Is the usage o...
Issue close #223 close #260 Overview Replace completion handler with Swift Concurrency. Checklist Format code with SwiftLint (⌘B in Xcode) Resolve Xcode warning What to check Is the usage o...
koher
@uhooi Other Swift Flags に -Xfrontend -warn-concurrency を付けるのをオススメします。これで、 Swift 6 からコンパイルエラーになる違反を警告として上げてくれます。
@MainActor class ViewController { var isolatedCounter: Int = 0 func viewDidAppear() {} } @MainActor class State { var value: Int = 0 } class XViewController: ViewController { let state = State() override func viewDidAppear() { state.value += 1 } }
(edited)
Iceman
@swift-5.5.3 -warn-concurrency
@MainActor class ViewController { var isolatedCounter: Int = 0 func viewDidAppear() {} } @MainActor class State { var value: Int = 0 } class XViewController: ViewController { let state = State() override func viewDidAppear() { state.value += 1 } }
Issue close #223 close #260 Overview Replace completion handler with Swift Concurrency. Checklist Format code with SwiftLint (⌘B in Xcode) Resolve Xcode warning What to check Is the usage o...
Issue close #223 close #260 Overview Replace completion handler with Swift Concurrency. Checklist Format code with SwiftLint (⌘B in Xcode) Resolve Xcode warning What to check Is the usage o...
<stdin>:2:15: warning: initialization of immutable value 'x' was never used; consider replacing with assignment to '_' or removing it async let x = Task<Int, Never> { print("task started"); return 1 }.result ~~~~^ _
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
便乗して質問なのですが…、テストを書いている時にawaitをautoclosureで使えないので、XCTAssertEqualなどに入れる前に変数にawaitの結果を入れているのですが、何かもっと良い方法はありますでしょうか? await' in an autoclosure that does not support concurrency(edited)
なるほど、みなさんありがとうございます! async let では実行タイミングが保証されないとのことなので、できるなら処理の入れ替えで対応したほうがベターということですね!
shiz
便乗して質問なのですが…、テストを書いている時にawaitをautoclosureで使えないので、XCTAssertEqualなどに入れる前に変数にawaitの結果を入れているのですが、何かもっと良い方法はありますでしょうか? await' in an autoclosure that does not support concurrency (edited)
Issue close #223 close #260 Overview Replace completion handler with Swift Concurrency. Checklist Format code with SwiftLint (⌘B in Xcode) Resolve Xcode warning What to check Is the usage o...
便乗して質問なのですが…、テストを書いている時にawaitをautoclosureで使えないので、XCTAssertEqualなどに入れる前に変数にawaitの結果を入れているのですが、何かもっと良い方法はありますでしょうか? await' in an autoclosure that does not support concurrency (edited)
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0296-async-await.md at main · apple/swift-evolution
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0329-clock-instant-date-duration.md at 523636b879cd6cab83124abc11060b6b39c3ac...
Test Suite 'All tests' started at 2021-12-16 04:09:15.831 Test Suite 'bin.xctest' started at 2021-12-16 04:09:15.832 Test Suite 'ATest' started at 2021-12-16 04:09:15.832 Test Case 'ATest.testFoo' started at 2021-12-16 04:09:15.832 Test Case 'ATest.testFoo' passed (0.001 seconds) Test Suite 'ATest' passed at 2021-12-16 04:09:15.833 Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds Test Suite 'bin.xctest' passed at 2021-12-16 04:09:15.833 Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds Test Suite 'All tests' passed at 2021-12-16 04:09:15.833 Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Issues close #223 close #260 Overview Use Swift Concurrency. Details Replace completion handler with async function Add @MainActor to All View ( UIViewController , UICollectionViewCell etc) All...
Issues close #223 close #260 Overview Use Swift Concurrency. Details Replace completion handler with async function Add @MainActor to All View ( UIViewController , UICollectionViewCell etc) All...
__attribute__((swift_attr("swift attribute"))). A general-purpose Objective-C attribute to allow one to provide Swift attributes directly. In the context of concurrency, this allows Objective-C APIs to be annotated with a global actor (e.g., @MainActor)
__attribute__((swift_attr("swift attribute"))). A general-purpose Objective-C attribute to allow one to provide Swift attributes directly. In the context of concurrency, this allows Objective-C APIs to be annotated with a global actor (e.g., @MainActor)
返事遅れてすいません まだデバックの仕方も良く分からずなのですが、シュミレーションすると、 fopen failed for data file: errno = 2 (No such file or directory) と出るので分割したクラス側で画像を参照できていないのかと思っていました 今現在もググって解決法を模索中です。 もしかしたらラベルが出ていないだけかもしれないので色々試しています。 色んな記事を読むと値渡しがswiftの初心者の壁みたいなの
You should only access a state property from inside the view’s body, or from methods called by it. For this reason, declare your state properties as private, to prevent clients of your view from accessing them.
おお…そうなのですね…。 まだちょっと納得がいっていなくて、これは Constructor Injection だから DI っぽく見えるだけな気がしてしまうんですよね。 この意見だと Setter Injection でも DI と呼ぶということでしょうか?
class FooInteractor { var httpClient: HTTPClient } class HTTPClient {} var interactor = FooInteractor() interactor.httpClient = HTTPClient() // ???: これも DI ?
継承できれば DI ということは、 HTTPClient でなくプリミティブ型だったら DI ではない?
import SwiftUI enum Components { case a(ComponentA) case b(ComponentB) } struct ComponentA: View { public var body: some View {} } struct ComponentB: View { public var body: some View {} }